<?php
/*
 * 分类聚合页
 * SF_CategoryPage_ClassificationController
 * SF_CategoryPage_Block_Such
 *
 */
?>

<?php
//产品配置项
    $homeUrl     = $this->getUrl('');//首页路径
    $this_store  = Mage::app()->getStore()->getStoreId();//视图判断
    $skin_url    = $this->getSkinUrl();//当前皮肤路径
    $img = ($this_store == '2') ? $skin_url.'images/landing-page/icod/ru/' : $skin_url.'images/landing-page/icod/en/';

    $codeName    = $this->codeName();//当前分类名称
    $codeName    =($this_store == '2') ? $codeName['1']:$codeName['0'];
?>

<!-- js -->
<script type="text/javascript">
    //<![CDATA[
    (function($){
        $('.em-header-style31').css("margin","0px");
        $('.em-wrapper-main .container-main').css({"margin":"0px","padding":"0px","width":"100%"});
        $('.em-main-container.em-col1-layout >div.row').css('margin','0');
        $('.em-main-container.em-col1-layout >div.row >div.em-col-main').css('padding','0');
    })(jQuery);
    //]]>
</script>
<div class="category">
    <div class="category_top_banner">
        <div class="categoryBack categoryBorder">
            <h3>
                <?php echo $codeName;?>
            </h3>
        </div>
        <ul>
            <li><a href="<?php echo $homeUrl ?>guarantee/"><img src="<?php echo $img ?>New_3.png" alt=""></a></li>
            <li><a href="<?php echo $homeUrl ?>delivery/"><img src="<?php echo $img ?>New_4.png" alt=""></a></li>
            <li><a href="<?php echo $homeUrl ?>about_rumall/"><img src="<?php echo $img ?>New_5.png" alt=""></a></li>
            <li><a href="<?php echo $homeUrl ?>returns_refunds/"><img src="<?php echo $img ?>New_6.png" alt=""></a></li>
            <li><a href="<?php echo $homeUrl ?>delivery/"><img src="<?php echo $img ?>New_7.png" alt=""></a></li>
            <li><a href="<?php echo $homeUrl ?>payment/"><img src="<?php echo $img ?>New_8.png" alt=""></a></li>
            <li><a href="<?php echo $homeUrl ?>about_rumall/"><img src="<?php echo $img ?>New_9.png" alt=""></a></li>
        </ul>
    </div>
<?php 
    $categoryIds = $this->categoryIds();//当前分类聚合页子分类Ids;
    $bannerIds   = $this->bannerIds();//当前分类聚合页banner;
?>
    <div class="category_content">
        <div>
            <div class="content_top">
                <div class="category_nav">
                    <h3><span><?php echo $codeName;?></span></h3>
                    <ul class="nav nav-tabs nav-stacked">
                        <?php foreach($categoryIds as $listId): ?>
                            <?php
                                $loadCategory = Mage::getModel('catalog/category')->load($listId);
                                $loadCate     = $loadCategory->getChildren();
                                $subCategories = explode(',',$loadCate);
                            ?>
                            <li class="dropdown">
                                <a href="<?php echo $loadCategory->getURL() ?>" title="<?php echo $loadCategory->getName() ?>" class="<?php if ($loadCate): ?>fa fa-caret-right<?php endif ?>"><span><?php echo $loadCategory->getName() ?></span> </a>
                                <?php if ($loadCate): ?>
                                     <ul class="dropdown-menu">
                                        <?php foreach ( $subCategories as $subCategoryId ): ?>
                                            <?php $cat = Mage::getModel('catalog/category')->load($subCategoryId); ?>
                                            <?php if($cat->getIsActive()) : ?>
                                                <li><a href="<?php echo $cat->getURL() ?>"  title="<?php echo $loadCategory->getName() ?>"><span><?php echo $cat->getName() ?></span></a><li>
                                            <?php endif; ?>
                                        <?php endforeach ?>
                                    </ul>                                   
                                <?php endif ?>
                            </li>
                        <?php endforeach ?>
                    </ul>
                </div>
                <div class="category_aside">
                    <?php echo $bannerIds ?>
                </div>
            </div>

            <div class="content_middle">
                <div>
                    <?php foreach($categoryIds as $categoryId): ?>
                        <?php
                            $collection  = $this->screenIds($categoryId,'10');
                        ?>
                    <?php if(count($collection) > 0 ): ?>
                    <div class="em-line-01 button-show01 button-hide-text" style="position: relative;">
                        <a name="activity_nav_'.$id.'"></a>
                        <div class="more">
                            <a href="<?php echo Mage::getModel('catalog/category')->load($categoryId)->getUrl(); ?>"><span><?php echo $this->__('more') ?> </span><span class="fa fa-angle-double-right">&nbsp;</span></a>
                        </div>
                        <div class="widget-title em-widget-title"><h3 class="categoryBorder categoryColor"><span><?php echo Mage::getModel('catalog/category')->load($categoryId)->getName(); ?></span></h3></div>
                        <div class="em-featured-slider">
                            <ul class="emcatalog-grid-mode products-grid emcatalog-disable-hover-below-mobile">
                            <?php foreach ($collection as $_product): ?>
                            <?php
                                $productImg    = $this->getMediaUrl('catalog/product/placeholder/default/placeholder-image-rumall.jpg');
                                $productUrl    = $_product->getProductUrl();
                                $productName   = $_product->getName();
                                $shortdes      = Mage::helper('core')->stripTags($_product->getShortDescription());
                                if(mb_strlen($shortdes, 'utf-8')>100) {
                                    $shortdes = rtrim(mb_substr($shortdes, 0, 100, 'utf-8')) . '...';
                                }
                            ?>
    <li class="item first col-sm-5">
        <div class="product-item">
            <div class="product-shop-top">
                <a href="<?php echo $productUrl ?>" title="<?php echo $productName ?>" class="product-image">
                    <img class="img-responsive em-alt-hover lazy" src="<?php echo $productImg;?>" data-original="<?php echo Mage::helper('catalog/image')->init($_product, 'thumbnail')->resize(190); ?>" alt="<?php echo $productName; ?>" />
                    <img class="img-responsive em-alt-org lazy" src="<?php echo $productImg;?>" data-original="<?php echo Mage::helper('catalog/image')->init($_product,'thumbnail')->resize(190); ?>" alt="<?php echo $productName; ?>" id="product-collection-image-<?php echo $_product->getId() ?>" />
                    <span class="bkg-hover"></span>
                </a>
                <div class="bottom">
                    <?php if($_product->isSaleable()): ?>
                        <!--show button add to cart-->
                        <button type="button" title="<?php echo Mage::helper('core')->quoteEscape($this->__('Add to Cart')) ?>" class="button btn-cart" onclick="setLocation('<?php echo $this->getAddToCartUrl($_product) ?>')"><span><span><?php echo $this->__('Add to Cart') ?></span></span></button>
                    <?php else: ?>
                        <p class="availability out-of-stock"><span><?php echo $this->__('Out of stock') ?></span></p>
                    <?php endif; ?>

                    <!--show button add to compare-wishlist-->
                    <ul class="add-to-links">
                        <?php if ($this->helper('wishlist')->isAllow()) : ?>
                            <li><a href="<?php echo $this->helper('wishlist')->getAddUrl($_product) ?>" class="link-wishlist" title="<?php echo $this->__('Add to Wishlist') ?>"><?php echo $this->__('Add to Wishlist') ?></a></li>
                        <?php endif; ?>
                        <?php if($_compareUrl=$this->getAddToCompareUrl($_product)): ?>
                            <li><a href="<?php echo $_compareUrl ?>" class="link-compare" title="<?php echo $this->__('Add to Compare') ?>"><?php echo $this->__('Add to Compare') ?></a></li>
                        <?php endif; ?>
                    </ul>
                </div>
            </div>

            <div class="product-shop">
                <div class="f-fix">
                    <!--product name-->
                    <h2 class="product-name text-center"><a href="<?php echo $productUrl ?>" title="<?php echo $productName ?>"><?php echo $productName ?></a></h2>

                    <!--show reviews-->
                    <div class="<?php if(Mage::helper('themeframework/settings')->getProductsGrid_ShowReviews() == 2):?>em-element-display-hover<?php endif;?> text-center">
                        <?php echo $this->getReviewsSummaryHtml($_product, 'short') ?>
                    </div>

                    <!--product price-->
                    <div class="text-center  <?php if(Mage::helper('themeframework/settings')->getProductsGrid_ShowPrice() == 2): ?>em-element-display-hover<?php endif;?>">
                        <?php echo $this->getPriceHtml($_product, true) ?>
                    </div>

                    <!--product description-->
                    <div class="desc std text-center em-element-display-hover"><?php echo $shortdes ?></div>
                </div>
            </div>
        </div>
    </li>
<?php endforeach ?>
                            </ul>
                        </div>
                    </div>
<?php endif ?>
<?php endforeach ?>
                </div>
            </div>
            <div class="content_icode"></div>
        </div>
    </div>
</div>

<script type="text/javascript">
    /* lie 图片懒加载 */
    (function($){
        $(function() {
            $("img.lazy").lazyload({
                event : "sporty",
                effect: "fadeIn"
            });
        });

        $(window).bind("load", function() {
            var timeout = setTimeout(function() {
                $("img.lazy").trigger("sporty")
            }, 5000);
        });
    })(jQuery);
    /* lie 图片懒加载 */
</script>